<template>
  <div>
    <a-button type="primary" @click="login">登录</a-button>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { message } from 'ant-design-vue';
import { useAppStore } from '~/N/store/modules';

const store = useAppStore();
const router = useRouter();

let formData = ref({
  username: 'admin',
  password: 'admin'
});

async function login() {
  try {
    await store.LOGIN(formData.value);
    router.push('/index');
    message.success('登录成功');
  } catch (error) {
    message.error(error);
  }
}
</script>

<style lang="scss" scoped></style>
